<?php
include'cnx.php';

class contenido 
{







function temas()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM temas limit 0,10";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function temas2()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM temas limit 10,10";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function temas3()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM temas order by codigo asc limit 0,30 ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function temas4()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM temas order by codigo asc limit 30,30 ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function temas5()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM temas order by codigo asc limit 60,30 ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function SelecTema($valor)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query="SELECT  t2.codigot as cod2, t2.nombre as nom2,t2.descripcion as descrip2, t1.codigo as cod1 FROM temas t1 INNER JOIN temas_artic t2 on t1.codigo=t2.codigo WHERE t2.codigo in ($valor)";
			
		
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}




function DetalleTema($valor)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM temas_artic  WHERE codigot = $valor";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}




function visitas($codV)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
			
			$query="update tb_temas set visitas=visitas+1   where id_tema = '$codV'";
					
			
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function temasbd()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_temas order by nombre asc limit 0,30 ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function temasbd2()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_temas order by nombre asc limit 30,30 ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function temasbd3()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_temas order by nombre asc limit 60,30 ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function DetalleTema2($valor)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_concepto  WHERE id_concep = $valor";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function Letras()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM letras ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function letraOrd($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_temas where id_tema not like '78' and  id_tema not like '83' and nombre like '$codV%'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function temasE()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			       
			$query = "SELECT  * FROM tb_temas  where id_tema not like '78' and  id_tema not like '83' and  id_tema not like '3' and  id_tema not like '6' and  id_tema not like '5'  order by visitas desc limit 0,10";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function temasE2()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_temas where id_tema not like '78' and  id_tema not like '83' and  id_tema not like '3' and  id_tema not like '6' and  id_tema not like '5' order by visitas desc limit 10,10";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}




function PalabraFrase($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			
			$query = "select te.id_tema as codtem , te.nombre as nomt from tb_temas te inner join tb_relac_tema relac on te.id_tema =relac.id_tema where relac.id_concep ='$codV'  ORDER BY te.nombre ASC limit 1,12";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}



function recurs1()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_recurso  where validar='si' order by id_recurso desc limit 0,4";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function recurs2()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_recurso where validar='si' order by id_recurso desc limit 4,4";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function DetTema($valor)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_temas  WHERE id_tema = $valor";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function DetRecurso($valor)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_recurso  WHERE id_recurso = $valor";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}
function recursos()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "SELECT  * FROM tb_recurso where validar='si'  order by post_date desc ";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function concepto_det($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_concepto where id_concep='$codV'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function concepto_actual($tit,$conten,$cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_concepto set titulo='$tit',concepto='$conten' where id_concep ='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function Recur_actual($tit,$conten,$cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="update tb_recurso set titulo='$tit',concepto='$conten' where id_recurso ='$cod'";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function temaInic($tem)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='$tem' and conc.validar='si' order by cod2 desc limit 0,1";
			
			
			
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function temaInicImg($tem)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha,conc.imagen as img from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_concep ='$tem' order by cod2 desc limit 0,1";
			
			
			
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function PalabraFrase1($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			
			$query = "select te.id_tema as codtem , te.nombre as nomt from tb_temas te inner join tb_relac_tema relac on te.id_tema =relac.id_tema where relac.id_concep ='$codV'  ORDER BY te.nombre ASC limit 0,1";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function idImg($ord)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_himg where id=$ord";
			
			
			
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}





function banners()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_concepto where validarimg='1'";
			
			
			
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}







function NovedB($tem,$lim)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha,conc.imagen as imagen from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='$tem' and conc.validar='si' order by cod2 desc limit $lim,1";
			
			
			
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}



function cancPrimer()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha,conc.video as video,conc.descripcion as descrip from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='83'  and conc.validar='si' order by conc.id_concep desc limit 0,1";
			
			
			//or relac.id_tema ='78'
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function cancPrimer2()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha,conc.video as video,conc.descripcion as descrip from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='78'  and conc.validar='si' order by conc.id_concep desc limit 0,1";
			
			
			//or relac.id_tema ='78'
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}

function cancPrimera()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha,conc.video as video,conc.descripcion as descrip from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='83'  order by conc.id_concep desc limit 0,1";
			
			
			//or relac.id_tema ='78'
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}


function cancPrimerb()
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
$query = "
			select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2,conc.post_date as fecha,conc.video as video,conc.descripcion as descrip from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='78'  order by conc.id_concep desc limit 0,1";
			
			
			//or relac.id_tema ='78'
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}







function Det_Imagen($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select * from tb_imagenes where idimag='$codV'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}




/////////

//function ingresar($cboEsp,$txtNombre)
//{
//	$con = new Conect;
//	if($con -> conectar() == true)
//		{
//			$query = "insert into datos(nombre,email)values('$cboEsp','$txtNombre')";			
//			$result = mysql_query($query);
//		if (!$result)
//			return false;
//		else
//			return $result;
//		}
//}

//function Actualizar($codN,$nomN,$cod)
//{
//	$con = new Conect;
//	if($con -> conectar() == true)
//		{
//						
//			$query="update tb_proyecamar2 set codigo= '$codN',  nombreNovio = '$nomN'  where Id = '$cod'";
//					
//			$result = mysql_query($query);
//		if (!$result)
//			return false;
//		else
//			return $result;
//		}
//}


//function Eliminar($codN)
//{
//	$con = new Conect;
//	if($con -> conectar() == true)
//		{
//			
//			
//			$query="Delete from tb_proyecamar2  where Id =$codN";
//					
//			$result = mysql_query($query);
//		if (!$result)
//			return false;
//		else
//			return $result;
//		}
//}


function CountN($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '3' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function CountV($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '78' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function CountW($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '6' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}
function CountT($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '5' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}

function CountM($cod)
{
	$con = new Conect;
	if($con -> conectar() == true)
		{
						
			$query="SELECT *  from tb_relac_tema WHERE id_tema =  '83' and    id_concep
    IN 
   ( 
    SELECT  id_concep  from tb_relac_tema WHERE id_tema =  '$cod'
) ";
					
			$result = mysql_query($query);
		if (!$result)
			return false;
		else
			return $result;
		}
}




function CountTem($codV)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			$query = "select relac.id_tema as cod1,conc.id_concep as cod2,conc.titulo as nom2 from tb_concepto conc inner join tb_relac_tema relac on conc.id_concep =relac.id_concep  where relac.id_tema ='$codV' and conc.validar='si'";
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}



function libros($lim,$validar)
{
	
	$con = new Conect;
	if($con -> conectar() == true)
		{
			if ($validar==1)
			{
			$query = "SELECT  * FROM tb_libros where validar='si'  order by id_recurso desc limit 0,$lim";
			}
			else
			{
				$query = "SELECT  * FROM tb_libros   order by id_recurso desc limit 0,$lim";
				}
			
			$result = mysql_query($query);
		 if (!$result)
			return false;
		 else
			return $result;
	   }
}





}
?>
